<?php

import('ORG.Util.String');

/*
Module Group: product
Module Group Name: 产品
Description: 产品模块用于展示产品信息
Version: 1.0
Iconurl: http://www.happyidea.com.cn/resource/wx_icon/default.png
Author: lr
Modules: product
Display: 1
*/
define('type_order', 'order');
define('type_takeout', 'takeout');
define('type_point_interact_display', '互动积分兑换');
define('type_point_consume_display', '消费积分兑换');
define('fake', 'fake_');
class productModule extends Module {
	
	/*
	 * 在构造函数中装载所依赖的类或其他文件
	*/
	function __construct() {
		$this->includePhp('product', 'product');
	}
	
	/*
	 * 激活创建数据库
	*/
	public function activate() {
		Module::importSQL ( module_sql_path ( 'product' ) );
	}
	
	/*
	 * 调用插件资源
	*/
	public function call($user, $method, $param) {
		switch ($method) {
			case 'crowdStall':
				$id = $param->id;
				if (!isset($id)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				product::crowdStall($id);
				break;
			case 'orderDishes':
				$sid = $param->sid;
				if (!isset($sid)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				$userName = $user['userName'];
				if ($userName == '') {
					$userName = uniqid(fake);
				}
				product::getStoreProduct($sid, type_order, $userName);
				break;
			case 'takeoutDishes':
				$sid = $param->sid;
				if (!isset($sid)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				$userName = $user['userName'];
				product::getStoreProduct($sid, type_takeout, $userName);
				break;
			case 'updateOrderDetail':
				$pid = $param->pid;
				$count = $param->count;
				$type = $param->type;
				$sid = $param->sid;
				if (!isset($count) || !isset($type)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				if (!isset($param->oid)) {
					$param->oid = 0;
				} else {
					$param->oid;
				}
				product::updateOrderDetail($param);
				break;
			case 'SendorderNotice':
				product::SendorderNotice($param);
				break;
			case 'removeOrderDetail':
				$userName = $user['userName'];
				product::removeOrderDetail($param);
				break;
			case 'preSubmitOrder':	// 立即购买未提交的订单
				$pids = $param->pids; // 购买的产品id,为－1时默认为所有购物车产品
				$counts = $param->counts;
				$type = $param->type;
				$dids=$param->dids;
// 				Log::write('preOrder counts is:'.$counts);
				if(!$dids) {
					if (!isset($pids) || !isset($counts) || !isset($type)) {
						Output::instance()->resultCode(code_lackof_param);
						return;
					}
					if(!isset($param->colors) || empty($param->colors)) {
						$colors = null;
					} else {
						$colors = $param->colors;
					}
					if(!isset($param->sizes) || empty($param->sizes)) {
						$sizes = null;
					} else {
						$sizes = $param->sizes;
					}
				}
				
				if(!isset($param->noNeedJsonResult)){
					$noNeedJsonResult = true;
				} else {
					$noNeedJsonResult = $param->noNeedJsonResult;
				}
				
				// if($noNeedJsonResult){
				// 	product::preSubmitOrder($sid, $pids, $counts, $type, $sizes, $colors,$noNeedJsonResult);
				// }else{
				// 	$order = product::preSubmitOrder($sid, $pids, $counts, $type, $sizes, $colors,$noNeedJsonResult);
				// 	return $order;
				// }
				if($noNeedJsonResult){
					product::preSubmitOrder($param,$noNeedJsonResult);
				}else{
					$order = product::preSubmitOrder($param,$noNeedJsonResult);
					return $order;
				}
				break;
			case 'submitOrder':
				$userName = $user['userName'];
				$sid = $param->sid;
				if(isset($param->price)) {
					$price = $param->price;
				}
				if(isset($param->srname)) {
					$storeResourceName = $param->srname;
				}
				if(isset($param->srid)) {
					$storeResourceId = $param->srid;
				}
				$fullName = $param->fullName;
				$address = $param->address;
				$phone = $param->phone;
				$customInfo = $param->customInfo;
				$verifyPhone = $param->verifyPhone;
				$IDName = $param->IDName;
				$IDNumber = $param->IDNumber;
				$IDPositive = $param->IDPositive;
				$IDBack = $param->IDBack;
				$type = $param->type;
				$remark = $param->remark;
				$bankNum = $param->bankNumber;
				if(isset($param->ordertime)) {
					$orderTime = $param->ordertime;
				}
				$payType = $param->paytype;
				$deliveryType = $param->dtype;
				if (!isset($sid) || !isset($type)) {
//                    var_dump('h1');
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				if ($type == type_order && (!isset($price) || !isset($storeResourceId) || !isset($storeResourceName))) {
//                    var_dump('h2');
                    Output::instance()->resultCode(code_lackof_param);
					return;
				} else if ($type == type_buy && (!isset($address) || !isset($fullName) || !isset($phone)) ) {
//                    var_dump('h4');
                    Output::instance()->resultCode(code_lackof_param);
					return;
				}
				if (!isset($price)) {
					$price = '';
				}
				if (!isset($storeResourceId)) {
					$storeResourceId  =  0;
				}
				if (!isset($storeResourceName)) {
					$storeResourceName = '';
				}
				if (!isset($orderTime)) {
					$orderTime = NULL;
				}
				// id set is after presubmitorder, not set is dish order or takeout or using cart oid = 0
				if (isset($param->id)) {
					$id = $param->id;
				}
				$joinQuan = $param->joinQuan;//加入合伙人订单
				$wxNumber = $param->wxId;
                $invoiceTitle = (isset($param->invoiceTitle)) ? $param->invoiceTitle : NULL;
                $invoiceTitleName = (isset($param->invoiceTitleName)) ? $param->invoiceTitleName : NULL;
                $invoiceMethodName = (isset($param->invoiceMethodName)) ? $param->invoiceMethodName : NULL;
                $invoiceContentName = (isset($param->invoiceContentName)) ? $param->invoiceContentName : NULL;
				$userCouponId=$param->userCouponId;
				$purseMoney = $param->purseMoney;
				$province = $param->province;
				$city = $param->city;
				$country = $param->country;
				$logisticsStatue = $param->logisticsStatue;
				product::submitOrder($id, $sid, $price, $remark, $fullName, $phone,$province,$city,$country, $address, $orderTime,
						$storeResourceId, $storeResourceName, $type, $payType, $deliveryType, $userName,
                    $invoiceTitle, $invoiceTitleName, $invoiceMethodName, $invoiceContentName,$IDName,$IDNumber,
					$IDPositive,$IDBack,$userCouponId,$joinQuan,$wxNumber,$purseMoney,$logisticsStatue,$verifyPhone,'',$bankNum, $customInfo);
				break;
			case 'cancelWxOrder':
				// wxpay pay failed, revert deduct inventory
				$oid = $param->oid;
				if (!isset($oid)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				product::cancelWxOrder($oid);
				break;
			case 'getProductByTagId':
				$tagIds = $param->tagId;
                $title = $param->title;
				$type = $param->type;
				$mallid = $param->mallid;
				$cids = $param->cids;
				$sid = $param->sid;
				$start = $param->start;
				$limit = (isset($param->limit)) ? $param->limit : 10;
				if (!isset($tagIds)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				if (!isset($param->tplid)) {
					$tplId = 0;
				} else {
					$tplId = $param->tplid;
				}

                $counts = NULL;
                if (isset($param->counts)) {
                    $counts = $param->counts;
                }
                $headerpic = NULL;
                if (isset($param->headerpic)) {
                    $headerpic = $param->headerpic;
                }
                $moduleType = NULL;
                if (isset($param->moduleType)){
                    $moduleType = $param->moduleType;
                }
				$qId = $param->qId;
				$miUId = $param->miUId;
				$visitId = $param->visitId;
				$lastShareUId = $param->lastShareUId;
                product::getProductByTagId($tplId, $sid, $tagIds, $cids, $type,$mallid, $start,$limit, null, $counts, $headerpic, $title, $moduleType,$qId,$miUId,$visitId,$lastShareUId);
				break;
			case 'getCart':
			case 'getMenu':
				$type = $param->type;
				$sid = $param->sid;
				$token = $param->token;
				if (!isset($type) || !isset($sid)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				$userName = $user['userName'];
				$rootId = $param->rootid;
				if (!isset($param->tplid)) {
					$tplId = 0;
				} else {
					$tplId = $param->tplid;
				}
				$qId=$param->qId;
				$miUId = $param->miUId;
				product::getMenu($tplId, $type, $sid, $userName, $rootId,$qId,$miUId,$token);
				break;
			case 'getCart':
				$type = $param->type;
				$token = $param->token;
				$sid = -1;
				if (!isset($type) || !isset($sid)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				$userName = $user['userName'];
				$rootId = $param->rootid;

				product::getCart($type,$sid, $userName, $rootId,$token);
				break;
			case 'realInfo':
				$oid = $param->oid;
				product::realInfo($oid);
				break;
			case 'getCarNum':
				$type = $param->type;
				$token = $param->token;
				product::getCarNum($type,$token);
				break;
			case 'getOrder':
				$type = $param->type;
				$status = $param->status;
				$search = $param->search;
				if (!isset($type)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				if (!isset($param->tplid)) {
					$tplId = 0;
				} else {
					$tplId = $param->tplid;
				}
				if (!isset($param->start)) {
					$start = 0;
				} else {
					$start = $param->start;
				}
				if (!isset($param->isnotsubmit)) {
					$isNotSubmit = false;
				} else {
					$isNotSubmit = $param->isnotsubmit;
				}
				$limit = 10;
				$rootId = $param->rootid;
				$token = $param->token;
				$userName = $user['userName'];
				product::getOrder($tplId, $type, $userName, $start, $limit,$status, $isNotSubmit, $rootId,$search,$token);
				break;
			case 'getOrderDetail':
				$id = $param->id;
				$token = $param->token;
				if (!isset($id)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				if (!isset($param->isShare)) {
					$isShare = false;
				} else {
					$isShare = $param->isShare;
				}
				if (!isset($param->sid)) {
					$sid = -1;
				} else {
					$sid = $param->sid;
				}
				if (!isset($param->tplid)) {
					$tplId = 0;
				} else {
					$tplId = $param->tplid;
				}
				if (!isset($param->type)) {
					$type = type_buy;
				} else {
					$type = $param->type;
				}
				$rootId = $param->rootid;
				$noNeedJsonResult = $param->noNeedJsonResult;
				if(!isset($noNeedJsonResult)){
					$noNeedJsonResult = true;
				}
				$notUse = $param->notUse;
				if($noNeedJsonResult){
					product::getOrderDetail($tplId, $id,$sid,$isShare,$type, $rootId,$noNeedJsonResult,$notUse,$token);
				}else{
					$orderDetail = product::getOrderDetail($tplId, $id,$sid,$isShare, $type, $rootId,$noNeedJsonResult,$notUse,$token);
					return $orderDetail;
				}
				break;
			case 'getProductByTag':
				if(!isset($param->tagid)){
					Output::instance()->resultCode(code_lackof_param);
				} 
				if (!isset($param->tplid)) {
					$tplId = 0;
				} else {
					$tplId = $param->tplid;
				}
				if (!isset($param->start)) {
					$start = 0;
				} else {
					$start = $param->start;
				}
				$qId = $param->qId;
				$miUId = $param->miUId;
				$limit = 10;
				$rootId = $param->rootid;
				product::getProductByTagId($tplId, '', $param->tagid, '', '', $start, $limit, $rootId,$qId,$miUId);
				break;
			case 'getProduct':
				$id = $param->id;
				if (!isset($id)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				if (isset($param->tplid)) {
					$tplId = $param->tplid;
				}
				if (isset($rootId)) {
					$rootId = $param->rootid;
				} else {
					$rootId = NULL;
				}
				
				if(!isset($param->allowOrder)){
					$allowOrder = 0;
				} else {
					$allowOrder = $param->allowOrder;
				}
				Log::write('test');
				
				$userName = $user['userName'];
				product::getProduct($param);
				break;
			case "getProductInventory":
				return product::getProductInventory($param);
				break;
            case 'getDiscountPrice':
                $pid = $param->pid;
                product::getDiscountPrice($pid);
                break;
			case 'getProductCategoryWithPdt':
				$cids = $param->cids;
				$tplId = $param->tplid;
				if (!isset($cids) || !isset($tplId)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				if (isset($param->rootid)) {
					$rootId = $param->rootid;
				} else {
					$rootId = NULL;
				}
				if (!isset($param->start)) {
					$start = 0;
				} else {
					$start = $param->start;
				}
				$limit = 10;

				product::getProductCategoryWithPdt($tplId, $cids, $start, $limit, $rootId);
				break;
			case 'getProductTagWithPdt':
				$tags = $param->tags;
				$tplId = $param->tplid;
				if (!isset($tags) || !isset($tplId)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				if (isset($param->rootid)) {
					$rootId = $param->rootid;
				} else {
					$rootId = NULL;
				}
				if (!isset($param->start)) {
					$start = 0;
				} else {
					$start = $param->start;
				}
				$limit = 10;
                $counts = NULL;
                if (isset($param->counts)) {
                    $counts = $param->counts;
                }
				product::getProductTagWithPdt($tplId, $tags, $start, $limit, $rootId, $counts);
				break;
			case 'getProductList':
				if (!isset($param->start)) {
					$start = 0;
				} else {
					$start = $param->start;
				}
				if (!isset($param->limit)) {
					$limit = 10;
				} else {
					$limit = $param->limit;
				}

				if (!isset($param->sid)) {
					$sid = 0;
				} else {
					$sid = $param->sid;
				}

				if (!isset($param->cids)) {
					$cids = 0;
				} else {
					$cids = $param->cids;
				}

				$type = $param->type;
				$tagIds = $param->tagIds;
				$orderBy = $param->orderBy;
				$screenTag = $param->screenTag;
				if (!isset($tagIds)&&!isset($screenTag)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				$userName = Session::$user['userName'];

				$arr = product::getProductList($sid, $tagIds, $cids, $userName, $type, $start, $limit,$orderBy,$screenTag);

				if ($arr) {
					$result["tagId"] = $cids;
					$result["total"] = $arr["total"];
					$result["results"] = $arr["productList"];
					$result["products"] = $arr;
					Output::instance()->object($result);
				} else {
					Output::instance()->resultCode();
				}
				break;
			case 'getProductListByCategory':
				$cid = $param->cid;
				if (!isset($cid)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
					
				if (!isset($param->start)) {
					$start = 0;
				} else {
					$start = $param->start;
				}
					
				$limit = 10;
				
				$userName = Session::$user['userName'];		
				$arr = product::getProductListByCategory($cid, $userName, $start, $limit);
				if ($arr) {
					$result["tagId"] = $cid;
					$result["total"] = $arr["total"];
					$result["results"] = $arr["productList"];
					$result["products"] = $arr;
					Output::instance()->object($result);
				} else {
					Output::instance()->resultCode();
				} 
				break;
			case 'getProductCategoryById':
				$ids = $param->id;
				$tplId = $param->tplid;
				if (!isset($ids) || !isset($tplId)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				if (isset($param->rootid)) {
					$rootId = $param->rootid;
				} else {
					$rootId = NULL;
				}
				if (!isset($param->start)) {
					$start = 0;
				} else {
					$start = $param->start;
				}
				$limit = 10;
				product::getProductCategoryById($tplId, $ids, $start, $limit, $rootId);
				break;
			case 'getFavorite':
				$userName = Session::$user['userName'];
//				if ($userName == '') {
//					Output::instance()->resultCode(code_lackof_param);
//					return;
//				}
				$rootId = $param->rootid;
				if (isset($param->tplid)) {
					$tplid = $param->tplid;
				} else {
					$tplid = 1;
				}
				if (isset($param->start)) {
					$start = $param->start;
				} else {
					$start = 0;
				}
				$param->limit?$limit=$param->limit:$limit = 10;
				$token = $param->token;
				product::getProductFavorite($tplid, $userName, $start, $limit, $rootId,$token);
				break;
			case 'getFavoriteNext':
				$userName = $user['userName'];
				$start = $param->start;
				$limit = 10;
				product::getProductFavoriteNext($userName, $start, $limit);
				break;
			case 'addFavorite':
				$id = $param->id;
				$token = $param->token;
				if (!isset($id)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				product::addFavorite($id,$token);
				break;
			case 'removeFavorite':
				$id = $param->id;
				if (!isset($id)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				$userName = $user['userName'];
				product::removeFavorite($id, $userName);
				break;
			case 'list':
				$tagId = $param->tid;
				if (!isset($tagId)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				product::getProductTag($tagId);
				break;
			case 'getAddr':
				$tplId = $param->tplid;
				if (!isset($tplId)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				$rootId = $param->rootid;
				$userName = $user['userName'];

				product::getAddr($userName, $rootId,$tplId);
				break;
			case 'getPickUp':
				$oid = $param->oid;
				if (!isset($oid)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				product::getPickUp($oid);
				break;
			case 'getPickupStore':
				$code = $param->code;
				$parentId = $param->parentId;
				$sort = $param->sort;
				$name = $param->name;
				$oid=$param->oid;
				if (!isset($oid)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				product::getPickupStoreList($oid,$code,$parentId,$sort,$name);
				break;
			case 'updateUserInfo':
				$userName = $param->uId;
//				if ($userName == '') {
//					Output::instance()->resultCode(code_lackof_param);
//					return;
//				}
				$fullName = $param->fullname;
				$phone = $param->phone;
				$address = $param->address;
				$storeId = $param->sid;
				$storeName = $param->sname;
				$deliveryType = $param->deliverytype;
				$IDName = $param->IDName;
				$IDNumber = $param->IDNumber;
				$IDPositive =$param->IDPositive;
				$IDBack = $param->IDBack;
				$oId = $param->oId;
				product::updateUserInfo($userName, $fullName, $phone, $address, $storeId, $storeName,$deliveryType,$IDName,$IDNumber,$IDPositive,$IDBack, $oId);
				break;
			case 'getOrderInfo':
				$id = $param->id;
				$fromUserName = $param->fromUserName;
				$sid = $param->sid;
				$type = $param->type;
				if (!isset($id) || !isset($fromUserName)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				$result = product::getOrderInfo($id, $fromUserName,$type);
				return $result;
				break;
			case 'getAddrSign':
				$url = $param->url;
				if (!isset($url)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				product::getAddrSign($url);
				break;
			case 'orderSuccess':
				$id = $param->id;
				$sendId = $param->sendId;
				if (!isset($id)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				product::getOrderSuccess($id,$sendId);
				break;
			case 'virtualSuccess':
				$id = $param->id;
				if (!isset($id)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				product::virtualSuccess($id);
				break;
			case 'updateOrderStatus':
				$id = $param->id;
				if (!isset($id)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				product::updateOrderStatus($id);
			case 'getMul':
				product::getMul();
				break;
			case 'sendNotice':
				$id = $param->id;
				$param->userName=$user['userName'];
				return product::sendNotice($param);
				break;
			case 'orderPayCallback':
				$id = $param->id;
				$userName = $param->userName;
				product::orderPayCallback($param);
				break;
			case 'cancelOrder':
				$id = $param->id;
				if (!isset($id)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				product::cancelOrder($id);
				break;
			case 'productOrderRefund':
				$ids = $param->id;
				if (!isset($ids)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				product::orderRefund($ids);
				break;
				//ihziluoh 添加商品评价
			case 'getcomment':
            	$pid = $param->pid;
            	$oid=$param->oid;
            	if (!isset($pid)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				if (!isset($oid)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
            	product::getcomment($param);
            	break;
            case 'saveComment':
           	 	$pid = $param->pid;
            	$oid=$param->oid;
				$imgUrls=$param->imgs;
            	$comment=$param->comment;
            	if (!isset($pid)||!isset($oid)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
            	product::saveComment($param);
            	break;
			 case 'getcommentList':
            	$pid = $param->pid;
            	$start=$param->start;
            	$limit=$param->limit;
            	product::getcommentList($pid,$start,$limit);
            	break;
            case 'getObjectDetail':
            	$id = $param->id;
            	if (!isset($id)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
            	return product::getObjectDetail($param);
            	break;
			case 'setOrderStatus':
				$oid = $param->oid;
				$status = $param->status;
				$expressNo = $param->expressNo;
				$expressName = $param->expressName;
				product::setOrderStatus($oid,$status,$expressNo,$expressName);
				break;
		
			case 'productExpress':			         
				  $express = $param->Express;
				  $orderNum= $param->orderNum;
				  $ord = $param->order;
				  $oid = $param->oid;
				  if(!isset($ord)){
				      $ord='asc';
				  }
				  if (!isset($express) ||  !isset($orderNum)) {
				      Output::instance()->resultCode(code_lackof_param);
				      return;
				  }			    
				  product::productExpress($oid,$express,$orderNum,$ord);
			 break;
            case 'IndianaList':
                product::getIndianaList($param);
                break;
			case 'sendCouponToUser':
				$schemeId=$param->schemeId;
				$oid=$param->oid;
				$status = $param->status;
				$token = $param->token;
				if (!isset($schemeId)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				product::sendCouponToUser($schemeId,$oid,$status,$token);
				break;
			case 'couponList':
				$oid = $param->oid;
				$type=$param->type;
				$start=$param->start;
				$limit=$param->limit;
				$token=$param->token;
				product::getCouponList($oid,$type,$start,$limit,$token);
				break;
			case 'couponIndex':
				$sendId=$param->sendId;
				if (!isset($sendId)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				product::couponIndex($sendId);
				break;
			case 'receiveCoupon':
				$sendId=$param->sendId;
				$token=$param->token;
				if (!isset($sendId)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				product::receiveCoupon($sendId,$token);
				break;
			case 'updateOrderCoupon':
				$oid = $param->oid;
				$userCouponId=$param->userCouponId;
				if (!isset($oid)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				product::updateOrderCoupon($oid,$userCouponId);
				break;
			case 'couponEmpty':
				Output::instance()->module("product","product_module_coupon_empty")->object(null);
				break;
			case 'toSearch':
				product::toSearch();
				break;
			case 'delSearchHistory':
				product::delSearchHistory();
				break;
            case 'scanCouponCode':
                product::scanCouponCode($param);
                break;
            case 'scanedCode':
                product::scanedCode($param);
                break;
			case 'searchProduct':
				$keyword = $param->keyword;
				$qId = $param->qId;
				$miUId = $param->miUId;
				if (!isset($keyword)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				product::searchProduct($keyword,$qId,$miUId);
				break;
			case 'searchResults':
				$keyword = $param->keyword;
				$start = $param->start;
				$limit = $param->limit;
				if (!isset($keyword)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				product::searchResults($keyword,$start,$limit);
				break;
			case 'getMallHue':
				return product::getMallHue();
				break;
			case 'getAreaJson'://地址json
				return product::getAreaJson();
				break;
            case 'couponInfo':
                $id = $param->id;
                if (!isset($id)) {
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                product::couponInfo($id);
                break;
            case 'receiveShareCoupon':
                $id = $param->id;
                if (!isset($id)) {
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                product::receiveShareCoupon($id);
                break;
			case 'getAddressList': //获取用户地址列表
				$isActivity = $param->isActivity;
				return product::getAddressList($isActivity);
				break;
			case 'createUserAddress': //创建更新用户地址
				$addressid = $param->id;
				$isActivity = $param->isActivity;
				$fullName = $param->fullname;
				$phone = $param->phone;
				$province = $param->province;
				$city = $param->city;
				$country = $param->country;
				$address = $param->address;
				$postcode = $param->postcode;
				return product::createUserAddress($addressid, $isActivity, $fullName, $phone, $province, $city, $country, $address, $postcode);
				break;
			case 'editUserAddress':
				$addressid = $param->id;
				return product::editUserAddress($addressid);
				break;
			case'deleteUserAddress'://删除用户地址
				$addressid = $param->id;
				return product::deleteUserAddress($addressid);
				break;
			case'setDefaultAddress':
				$addressid = $param->id;
				$isActivity = $param->isActivity;
				return product::setDefaultAddress($addressid,$isActivity);
				break;
			case "updateWeixinAddress":
				$fullName = $param->fullname;
				$phone = $param->phone;
				$address = $param->address;
				$province = $param->province;
				$city = $param->city;
				$country = $param->country;
				$isAcitivity = $param->isAcitivity;
				return product::updateWeixinAddress($fullName,$phone,$province,$city,$country,$address,$isAcitivity);
				break;
			case "orderBrowserOpen":
				$id = $param->id;
				$type = $param->type;
				$bankNum = $param->bankNum;
				product::orderBrowserOpen($id,$type,$bankNum);
				break;
            case 'commentRequire':
                $id = $param->id;
                return product::commentRequire($id);
                break;
			case 'preSubmitFormOrder':
				$miUid = $param->miUid;
				$qId = $param->qId;
				$sId = $param->sId;
				$visitId = $param->visitId;
				$formId = $param->formId;
				$customizedInfo = $param->customizedInfo;
				$module = $param->module;
				$moduleId = $param->moduleId;
				product::preSubmitFormOrder($miUid, $qId, $sId, $visitId, $formId,
					$customizedInfo,$module,$moduleId);
				break;
			case 'formOrderPay':
				$orderId = $param->orderId;
				$payType = $param->payType;
				return product::formOrderPay($orderId, $payType);
				break;
		}
	}
}


$module = new productModule();
Module::addModule($module);